﻿// test1.cpp: 定义应用程序的入口点。
//

#include "test2.h"
#include "application/Application.h"
#include "wrapper/checkerror.h"

using namespace std;

/*
* 创建窗体的过程
* 1、初始化GLFW的基本环境
* 2、创建窗体对象
* 3、执行窗体循环
*/

void framebuffer_size_callback(GLFWwindow* window, int width, int height);
void processInput(GLFWwindow* window);

//设置窗口的宽高
const unsigned int SCR_WIDTH = 800;
const unsigned int SCR_HEIGHT = 600;

//void keyCallBack(GLFWwindow* window, int key, int scancode, int action, int mods)
//{
//    if (key == GLFW_KEY_ESCAPE)
//        glfwSetWindowShouldClose(window, true);
//}

void OnResize(int width, int height) {
    std::cout << "OnResize" << std::endl;
    glViewport(0, 0, width, height);
}

void OnkeyCallBack(int key, int action, int mods)
{
    std::cout << key << std::endl;
        
}

int main()
{
    if(!app->init(800, 600)){
        return -1;
    }
    std::cout << "app init" << std::endl;

    // //窗体size回调
    // glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);

    // //设置按键监听，监听回调
    // glfwSetKeyCallback(window, keyCallBack);
    app->setResizeCallback(OnResize);
    app->setKeyBoardCallback(OnkeyCallBack);

    //窗体循环
    //渲染
    while (app->update())
    {

        // render
       // ------
        glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
        GL_CALL(glClear(GL_COLOR_BUFFER_BIT));
        checkError();

    }

    //释放
    app->destory();
    return 0;
}



//void framebuffer_size_callback(GLFWwindow* window, int width, int height)
//{
//    glViewport(0, 0, width, height);
//}